from time import sleep

from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction

caps = {
    'platformName': 'Android',
    'platformVersion': '5.1.1',
    'deviceName': 'NNN',
    'appPackage': 'com.android.settings',
    'appActivity': '.Settings'}
driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub',
                          desired_capabilities=caps
                          )
TA = TouchAction(driver)
wlan = driver.find_element_by_xpath('//*[@text = "WLAN"]')
app = driver.find_element_by_xpath('//*[@text = "应用"]')
#
# TA.tap(wlan)
# TA.perform()
driver.scroll(origin_el=app,destination_el=wlan,duration=3000)
anquan  = driver.find_element_by_xpath('//*[@text = "安全"]')
anquan.click()

suoding = driver.find_element_by_xpath('//*[@text = "屏幕锁定方式"]')
suoding.click()

sleep(2)
huadong = driver.find_element_by_xpath('//*[@text = "图案"]')
huadong.click()

driver.get_screenshot_as_file('111.png')
driver.save_screenshot('222.png')
TA.long_press(x=751, y=356, duration=1000)
TA.move_to(x=952, y=356)
TA.move_to(x=1170, y=360)
TA.move_to(x=1170, y=570)
TA.move_to(x=1170, y=770)

TA.perform()

sleep(2)
driver.quit()
